/*******************************************************************************
 * Copyright (c) 2012 Daniele Parisi.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Daniele Parisi
 *     neb.inf@gmail.com
 *     http://www.danieleparisi.com/
 ******************************************************************************/
package org.jxreport.main;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;

import org.jxreport.html.HTMLReportGenerator;

public class Main {

	public static void main(String[] args) {
		try {
			
			String xmlFile = null;
			String htmlFile = null; 
			
			try{
			xmlFile = args[0];
			htmlFile = args[1];
			} catch(Exception e ){
				xmlFile = "test.xml";
				htmlFile = "test.html";
			}
			
			System.out.println("/************** jxReport *******************/");
			System.out.println("/* Xml File Name: " + xmlFile + "*/");
			System.out.println("/* Html File Name: " + htmlFile + "*/");
			
			HTMLReportGenerator htmlReport = new HTMLReportGenerator(new FileInputStream(new File(xmlFile)), null);

			try {
				BufferedWriter out = new BufferedWriter(new FileWriter(htmlFile));
				out.write(htmlReport.getHTMLCode());
				out.close();
			} catch (IOException e) { e.printStackTrace(); }

			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
